import 'package:flutter/material.dart';

class CorrectOrWrong extends StatefulWidget {
  final _isCorrect;
  final VoidCallback _onTap;
  CorrectOrWrong(this._isCorrect, this._onTap);

  @override
  State<StatefulWidget> createState() => new CorrectOrWrongState();
}

class CorrectOrWrongState extends State<CorrectOrWrong>
    with TickerProviderStateMixin {
  Animation<double> _iconAnimation;
  AnimationController _iconAnimationController;

  @override
  void initState() {
    super.initState();
    _iconAnimationController = new AnimationController(
        duration: new Duration(seconds: 2), vsync: this);
    _iconAnimation = CurvedAnimation(
        parent: _iconAnimationController, curve: Curves.elasticOut);
    _iconAnimationController.addListener(() {
      setState(() {});
    });
    _iconAnimationController.forward();
  }

  @override
  void dispose(){
     _iconAnimationController.dispose();
      super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.black54,
      child: new InkWell(
        onTap: widget._onTap,
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Container(
              decoration: new BoxDecoration(
                color: Colors.white,
                shape: BoxShape.circle,
              ),
              child: new Icon(
                widget._isCorrect == true ? Icons.done : Icons.clear,
                size:  _iconAnimation.value * 70.0,
              ),
            ),
            new Text(
              widget._isCorrect == true ? 'Correct' : 'Wrong',
              style: new TextStyle(
                  fontSize: 45.0,
                  color: Colors.white,
                  fontWeight: FontWeight.bold),
            )
          ],
        ),
      ),
    );
  }
}
